import pytest
import allure
from pages.page import HomePage, InvoiceCollection, Accountant
from time import sleep


@allure.epic("票账税6.0发票采集")
class TestCollectInvoice:
    @allure.feature("记账报税")
    @allure.story("发票采集")
    @allure.title("一般纳税人会计页面发票采集")
    @allure.severity("normal")
    @pytest.mark.parametrize("company_name, title", [
        # ["湖北一般云取票自动化测试", "金蝶在线会计"],
        ["浙江会计云取票自动化测试", "金蝶在线会计"],
        # ["天津一般云取票自动化测试", "金蝶在线会计"],
        # ["广东会计云取票自动化测试", "金蝶在线会计"]
    ])
    def test_account_book_collect_01(self, user_driver, company_name, title):
        with allure.step("关闭弹窗"):
            HomePage(user_driver).pop_up_window_manage()
        with allure.step("关闭公告"):
            HomePage(user_driver).notice_manage()
        with allure.step("进入发票采集页面"):
            HomePage(user_driver).switch_to_default_content()
            HomePage(user_driver).enter_invoice_collection()
        with allure.step("输入客户名称并搜索"):
            InvoiceCollection(user_driver).enter_invoice_collection_iframe()
            InvoiceCollection(user_driver).input_company_search(company_name)
        with allure.step("进账簿"):
            current_window = InvoiceCollection(user_driver).current_window()
            InvoiceCollection(user_driver).enter_account_book()
        with allure.step("跳转页面"):
            Accountant(user_driver).switch_to_window(title)
        with allure.step("进项票"):
            Accountant(user_driver).enter_income_invoice()
        with allure.step("智能采集"):
            Accountant(user_driver).initiate_income_invoice()
        with allure.step("断言"):
            Accountant(user_driver).income_invoice_result()
        with allure.step("返回主页面"):
            Accountant(user_driver).switch_to_current_window(current_window)
        with allure.step("关闭所有页签"):
            HomePage(user_driver).close_all_tab()

    # @allure.feature("记账报税")
    # @allure.story("发票采集")
    # @allure.title("小规模纳税人会计页面发票采集")
    # @allure.severity("normal")
    # @pytest.mark.parametrize("company_name, title", [
    #     # ["湖北小规模云取票自动化测试", "金蝶在线会计"],
    #     # ["浙江小规模云取票自动化测试", "金蝶在线会计"],
    #     # ["天津小规模云取票自动化测试", "金蝶在线会计"],
    #     ["广东小规模云取票自动化测试", "金蝶在线会计"]
    # ])
    # def test_account_book_collect_02(self, user_driver, company_name, title):
    #     with allure.step("关闭弹窗"):
    #         HomePage(user_driver).pop_up_window_manage()
    #     with allure.step("进入发票采集页面"):
    #         HomePage(user_driver).switch_to_default_content()
    #         HomePage(user_driver).enter_invoice_collection()
    #     with allure.step("切换至小规模tab页"):
    #         InvoiceCollection(user_driver).tab_select()
    #     with allure.step("输入客户名称并搜索"):
    #         InvoiceCollection(user_driver).enter_invoice_collection_iframe_02()
    #         InvoiceCollection(user_driver).input_company_search(company_name)
    #     with allure.step("进账簿"):
    #         current_window = InvoiceCollection(user_driver).current_window()
    #         InvoiceCollection(user_driver).enter_account_book()
    #     with allure.step("跳转页面"):
    #         Accountant(user_driver).switch_to_window(title)
    #     with allure.step("进项票"):
    #         Accountant(user_driver).enter_income_invoice()
    #     with allure.step("智能采集"):
    #         Accountant(user_driver).initiate_income_invoice()
    #     with allure.step("断言"):
    #         Accountant(user_driver).income_invoice_result()
    #     with allure.step("返回主页面"):
    #         Accountant(user_driver).switch_to_current_window(current_window)
    #     with allure.step("关闭所有页签"):
    #         HomePage(user_driver).close_all_tab()
